package com.bdqn.service;

import com.bdqn.common.PageSupport;
import com.bdqn.mapper.SupplierMapper;
import com.bdqn.pojo.Supplier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("SupplierService")
public class SupplierServiceImpl implements SupplierService {

    @Resource
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> getSupName() {
        return supplierMapper.getSupName();
    }

    @Override
    public List<Supplier> getPageList(Supplier supplier, PageSupport page) {
        int pageNo = (page.getCurrentPageNo() -1) * page.getPageSize();
        return supplierMapper.getPageList(supplier,pageNo,page.getPageSize());
    }

    @Override
    public int count(Supplier supplier) {
        return supplierMapper.count(supplier);
    }

    @Override
    public Supplier queryId(Integer id) {
        return supplierMapper.queryId(id);
    }

    @Override
    public boolean update(Supplier supplier) {
        supplier.setUpdatedTime(new Date());
        return supplierMapper.update(supplier);
    }

    @Override
    public boolean delete(Integer supId) {
        return supplierMapper.delete(supId) == 1;
    }

    @Override
    public boolean add(Supplier supplier) {
        return supplierMapper.add(supplier) == 1;
    }
}
